﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/revoelectric.master" title="Meter | Revo" CodeFile="Meters.aspx.cs" Inherits="Meters" %>

<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="head">
</asp:Content>

<asp:Content ID="Content2" runat="server" ContentPlaceHolderID="widebarHeaderContentPlaceHolder">

</asp:Content>

<asp:Content runat="server" ID="home_menu" ContentPlaceHolderID="widebarBodyContentPlaceHolder">
    <form id="formMetersGrid" runat="server">
        <div>
	        <asp:GridView ID="GridViewMeters" runat="server" 
                AllowSorting="True" AutoGenerateColumns="False" DataSourceID="ccDb" 
                EnableModelValidation="True" BackColor="White" BorderColor="#999999" 
                BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical" 
                AllowPaging="True" DataKeyNames="id" DataMember="DefaultView" 
                ShowFooter="True">
                <AlternatingRowStyle BackColor="#DCDCDC" />
                <Columns>
                    <asp:BoundField DataField="install_date" HeaderText="Installation Date" 
                        SortExpression="install_date" />
                    <asp:BoundField DataField="model" HeaderText="Model" 
                        SortExpression="model" />
                    <asp:BoundField DataField="premise_id" HeaderText="Premise Id" 
                        SortExpression="premise_id" />
                </Columns>
                <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
                <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
                <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
                <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
            </asp:GridView>
            <asp:SqlDataSource ID="ccDb" runat="server" 
                ConnectionString="<%$ ConnectionStrings:onwindConnectionString %>" 
                SelectCommand="SELECT [install_date], [model], [premise_id], [id] FROM [meter]"
                InsertCommand="INSERT INTO [meter] ([install_date], [model], [premise_id]) VALUES (GETDATE(), @model, @premise_id)" 
                UpdateCommand="UPDATE [meter] SET [install_date]=@install_date, [model]=@model, [premise_id]=@premise_id WHERE [id]=@id">
            </asp:SqlDataSource>
        </div>
        <div>
            <asp:FormView ID="FormViewMeter" runat="server" BackColor="White" 
                BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" 
                DataSourceID="ccDb" EnableModelValidation="True" GridLines="Vertical" 
                DataKeyNames="id" DefaultMode="Insert">
                                    
                <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
                <InsertItemTemplate>
                    <h3>Add New Meter</h3>
                    <span class="txtLabel">Model:</span>
                    <asp:TextBox ID="modelTextBox" runat="server" 
                        Text='<%# Bind("model") %>' />
                    <br />
                    <span class="txtLabel">Premise Id:</span>
                    <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="ccDbi" 
                        DataTextField="street" DataValueField="id" Text='<%# Bind("premise_id") %>'>
                    </asp:DropDownList>
                    <asp:SqlDataSource ID="ccDbi" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:onwindConnectionString %>" 
                        SelectCommand="SELECT [id], [street], [province], [city], [country] FROM [premise]">
                    </asp:SqlDataSource>
                    <br />
                    <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                        CommandName="Insert" Text="Insert" />
                    &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                        CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                </InsertItemTemplate>
            </asp:FormView>  
        </div>
    </form> 
</asp:Content>
      
					   
